/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.intec.matsab.dao;

import edu.intec.matsab.persistence.Asignatura;
import edu.intec.matsab.persistence.PersistenceManager;
import edu.intec.matsab.persistence.Trimestre;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceException;
import javax.persistence.Query;

/**
 *
 * @author matilde
 */
public class TrimestreDAO extends BasicoDAO {

    public static List<Trimestre> getAllTrimestres() {
        EntityManagerFactory emf = PersistenceManager.getInstance().getEntityManagerFactory();
        EntityManager manager = emf.createEntityManager();

        List<Trimestre> listTrimestres = new ArrayList<Trimestre>();

        try {
            Query query = manager.createNamedQuery("Trimestre.AllTrimestres");
            listTrimestres = query.getResultList();

        } catch (PersistenceException exception) {
            exception.printStackTrace();
        } finally {
            manager.close();
        }

        return listTrimestres;
    }
    
}
